<template>
  <div class="oddgoodContent">
    <div class="oddgoodTitle">
      <div class="customerTitle">海川医药零货上架{{ systemTime }}日报</div>
      <el-button type="success" @click="saveOdddaily">保存</el-button>
    </div>
    <div class="customtr1">
      <div class="customText">客户</div>
      <div class="delivery">
        <div class="deliveryTop">完成</div>
        <div class="deliveryBottom">
          <span>补货(件)</span>
          <span>零货(条)</span>
          <span>内部倒货(条)</span>
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop">未完成</div>
        <div class="deliveryBottom">
          <span>补货(件)</span>
          <span>零货(条)</span>
          <span>内部倒货(条)</span>
        </div>
      </div>
      <div class="customText">异常(件/条)</div>
      <div class="completeText">完成时间点</div>
    </div>
    <div class="customtr2">
      <div class="customText wyLayout">陕西海通</div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            @input="calculateWcbhTotal"
            v-model="form.htWcBh"
            size="medium"
          />
        </div>
      </div>
      <div class="customText">
        <el-input
          @input="calculateWclhTotal"
          v-model="form.htWcLh"
          size="medium"
        />
      </div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            v-model="form.htWcNbdh"
            @input="calculateWcnbdhTotal"
            size="medium"
          />
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            @input="calculateWwcbhTotal"
            v-model="form.htWwcBh"
            size="medium"
          />
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            @input="calculateWwclhTotal"
            v-model="form.htWwcLh"
            size="medium"
          />
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            @input="calculateWwcnbdhTotal"
            v-model="form.htWwcNbdh"
            size="medium"
          />
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            @input="calculateycTotal"
            v-model="form.htYc"
            size="medium"
          />
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop noborder">
          <el-time-picker
            v-model="form.htWcsjd"
            placeholder=""
            value-format="HH:mm"
            format="HH:mm"
          >
          </el-time-picker>
        </div>
      </div>
    </div>
    <div class="customtr2">
      <div class="customText wyLayout">陕西伟业</div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            @input="calculateWcbhTotal"
            v-model="form.wyWcBh"
            size="medium"
          />
        </div>
      </div>
      <div class="customText">
        <el-input
          @input="calculateWclhTotal"
          v-model="form.wyWcLh"
          size="medium"
        />
      </div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            v-model="form.wyWcNbdh"
            @input="calculateWcnbdhTotal"
            size="medium"
          />
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            @input="calculateWwcbhTotal"
            v-model="form.wyWwcBh"
            size="medium"
          />
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            @input="calculateWwclhTotal"
            v-model="form.wyWwcLh"
            size="medium"
          />
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            @input="calculateWwcnbdhTotal"
            v-model="form.wyWwcNbdh"
            size="medium"
          />
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop">
          <el-input
            @input="calculateycTotal"
            v-model="form.wyYc"
            size="medium"
          />
        </div>
      </div>
      <div class="delivery">
        <div class="deliveryTop noborder">
          <el-time-picker
            v-model="form.wyWcsjd"
            placeholder=""
            value-format="HH:mm"
            format="HH:mm"
          >
          </el-time-picker>
        </div>
      </div>
    </div>
    <div class="customtr3">
      <div class="customText wyLayout">其他货主</div>
      <div class="customText">
        <el-input
          @input="calculateWcbhTotal"
          v-model="form.qtWcBh"
          size="medium"
        />
      </div>
      <div class="customText">
        <el-input
          @input="calculateWclhTotal"
          v-model="form.qtWcLh"
          size="medium"
        />
      </div>
      <div class="customText">
        <el-input
          v-model="form.qtWcNbdh"
          @input="calculateWcnbdhTotal"
          size="medium"
        />
      </div>
      <div class="customText">
        <el-input
          @input="calculateWwcbhTotal"
          v-model="form.qtWwcBh"
          size="medium"
        />
      </div>
      <div class="customText">
        <el-input
          @input="calculateWwclhTotal"
          v-model="form.qtWwcLh"
          size="medium"
        />
      </div>
      <div class="customText">
        <el-input
          @input="calculateWwcnbdhTotal"
          v-model="form.qtWwcNbdh"
          size="medium"
        />
      </div>
      <div class="customText">
        <el-input @input="calculateycTotal" v-model="form.qtYc" size="medium" />
      </div>
      <div class="completeText">
        <el-time-picker
          v-model="form.qtWcsjd"
          placeholder=""
          value-format="HH:mm"
          format="HH:mm"
        >
        </el-time-picker>
      </div>
    </div>
    <div class="customtr4">
      <div class="customText wyLayout">合计</div>
      <!-- <div class="customText"></div> -->
      <div class="customText">
        <el-input disabled v-model="wcbhTotal" size="medium" />
      </div>
      <div class="customText">
        <el-input disabled v-model="wclhTotal" size="medium" />
      </div>
      <div class="customText">
        <el-input disabled v-model="wcnbdhTotal" size="medium" />
      </div>
      <div class="customText">
        <el-input disabled v-model="wwcbhTotal" size="medium" />
      </div>
      <div class="customText">
        <el-input disabled v-model="wwclhTotal" size="medium" />
      </div>
      <div class="customText">
        <el-input disabled v-model="wwcnbdhTotal" size="medium" />
      </div>
      <div class="customText">
        <el-input disabled v-model="ycTotal" size="medium" />
      </div>
      <div class="completeText"></div>
    </div>
  </div>
</template>

<script>
import { dailyaddodd, dailylistodd } from "@/api/system/daily";
export default {
  data() {
    return {
      // 陕西海通零货条目数
      ids: null,
      systemTime: "",
      wcbhTotal: undefined,
      wclhTotal: undefined,
      wcnbdhTotal: undefined,
      wwcbhTotal: undefined,
      wwclhTotal: undefined,
      wwcnbdhTotal: undefined,
      ycTotal: undefined,
      // 伟业
      form: {
        rbSj: new Date().toISOString().split("T")[0],
        // 海通
        htWcBh: null,
        htWcLh: null,
        htWcNbdh: null,
        htWwcBh: null,
        htWwcLh: null,
        htWwcNbdh: null,
        htYc: null,
        htWcsjd: null,
        // 伟业
        wyWcBh: null,
        wyWcLh: null,
        wyWcNbdh: null,
        wyWwcBh: null,
        wyWwcLh: null,
        wyWwcNbdh: null,
        wyYc: null,
        wyWcsjd: null,
        // 其他货主
        qtWcBh: null,
        qtWcLh: null,
        qtWcNbdh: null,
        qtWwcBh: null,
        qtWwcLh: null,
        qtWwcNbdh: null,
        qtYc: null,
        qtWcsjd: null,
      },
    };
  },
  mounted() {
    // 创建一个 Date 对象
    const currentDate = new Date();
    // 获取当前年份
    const year = currentDate.getFullYear();
    // 获取当前月份（注意：月份是从 0 开始计数的，所以需要加 1）
    const month = currentDate.getMonth() + 1;
    // 获取当前日期
    const day = currentDate.getDate();
    // 打印年月日
    this.systemTime = `${year}年${month}月${day}日`;
    this.getoddlist();
  },
  beforeDestroy() {},
  methods: {
    saveOdddaily() {
      dailyaddodd(this.form).then((res) => {
        console.log(res);
        this.$modal.msgSuccess("新增成功");
        this.getoddlist();
      });
    },
    getoddlist() {
      dailylistodd().then((res) => {
        if (res.data) {
          this.form = res.data;
          this.wcbhTotal =
            Number(this.form.htWcBh) +
            Number(this.form.wyWcBh) +
            Number(this.form.qtWcBh);
          this.wclhTotal =
            Number(this.form.htWcLh) +
            Number(this.form.wyWcLh) +
            Number(this.form.qtWcLh);
          this.wcnbdhTotal =
            Number(this.form.htWcNbdh) +
            Number(this.form.wyWcNbdh) +
            Number(this.form.qtWcNbdh);
          this.wwcbhTotal =
            Number(this.form.htWwcBh) +
            Number(this.form.wyWwcBh) +
            Number(this.form.qtWwcBh);
          this.wwclhTotal =
            Number(this.form.htWwcLh) +
            Number(this.form.wyWwcLh) +
            Number(this.form.qtWwcLh);
          this.wwcnbdhTotal =
            Number(this.form.htWwcNbdh) +
            Number(this.form.wyWwcNbdh) +
            Number(this.form.qtWwcNbdh);
          this.ycTotal =
            Number(this.form.htYc) +
            Number(this.form.wyYc) +
            Number(this.form.qtYc);
        }
      });
    },
    calculateWcbhTotal() {
      this.wcbhTotal =
        Number(this.form.htWcBh) +
        Number(this.form.wyWcBh) +
        Number(this.form.qtWcBh);
    },
    calculateWclhTotal() {
      this.wclhTotal =
        Number(this.form.htWcLh) +
        Number(this.form.wyWcLh) +
        Number(this.form.qtWcLh);
    },
    calculateWcnbdhTotal() {
      this.wcnbdhTotal =
        Number(this.form.htWcNbdh) +
        Number(this.form.wyWcNbdh) +
        Number(this.form.qtWcNbdh);
    },
    calculateWwcbhTotal() {
      this.wwcbhTotal =
        Number(this.form.htWwcBh) +
        Number(this.form.wyWwcBh) +
        Number(this.form.qtWwcBh);
    },
    calculateWwclhTotal() {
      this.wwclhTotal =
        Number(this.form.htWwcLh) +
        Number(this.form.wyWwcLh) +
        Number(this.form.qtWwcLh);
    },
    calculateWwcnbdhTotal() {
      this.wwcnbdhTotal =
        Number(this.form.htWwcNbdh) +
        Number(this.form.wyWwcNbdh) +
        Number(this.form.qtWwcNbdh);
    },
    calculateycTotal() {
      this.ycTotal =
        Number(this.form.htYc) +
        Number(this.form.wyYc) +
        Number(this.form.qtYc);
    },
  },
};
</script>

<style lang="scss" scoped>
.oddgoodContent {
  width: 100%;
  height: 100%;
  ::v-deep .el-table__body-wrapper {
    border: 1px solid #181616;
  }
  .el-table--group::after,
  .el-table--border::after {
    background-color: #181616;
  }
  ::v-deep .el-table--enable-row-hover .el-table__body tr:hover > td {
    background-color: transparent;
  }
  ::v-deep .el-input__inner {
    height: 65px;
    line-height: 65px;
    border: none;
    text-align: center;
    color: #000000;
    width: 100%;
  }
  ::v-deep .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 100%;
  }
  ::v-deep .el-input--prefix .el-input__inner {
    border: none;
  }
  ::v-deep .el-table tr {
    height: 70px;
  }

  .oddgoodTitle {
    display: flex;
    align-items: center;
    .customerTitle {
      width: 100%;
      font-size: 24px;
      font-weight: 700;
      margin: 30px 0 40px 0;
    }
    ::v-deep .el-button--success {
      height: 36px;
    }
  }
  .customtr1 {
    width: 100%;
    height: 140px;
    border: 1px solid #e7dfdf;
    background: #05a5ff;
    display: flex;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    justify-content: space-around;
    .customText {
      width: 11.1%;
      height: 140px;
      line-height: 140px;
      text-align: center;
      border-right: 1px solid #e7dfdf;
    }
    .completeText {
      width: 11.1%;
      height: 140px;
      line-height: 140px;
      text-align: center;
    }
    .delivery {
      width: 33.35%;
      display: flex;
      flex-direction: column;
      .deliveryTop {
        height: 50%;
        line-height: 70px;
        border-right: 1px solid #e7dfdf;
      }
      .deliveryBottom {
        height: 50%;
        display: flex;
        justify-content: space-around;
        border-top: 1px solid #e7dfdf;
        span {
          width: 34%;
          height: 100%;
          line-height: 70px;
          text-align: center;
          border-right: 1px solid #e7dfdf;
        }
      }
    }
    .ReceiveNoSent {
      width: 20%;
      .deliveryTop {
        height: 50%;
        line-height: 70px;
        border-right: 1px solid #e7dfdf;
      }
      .deliveryBottom {
        height: 50%;
        display: flex;
        justify-content: space-around;
        border-top: 1px solid #e7dfdf;
        span {
          width: 50%;
          height: 100%;
          line-height: 70px;
          text-align: center;
          border-right: 1px solid #e7dfdf;
        }
      }
    }
  }
  .customtr2 {
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #181616;
    border-left: 1px solid #181616;
    border-right: 1px solid #181616;
    // background: #00d9ff;
    display: flex;
    justify-content: space-around;
    .customText {
      width: 11.1%;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-right: 1px solid #181616;
    }
    .wyLayout {
      font-weight: 700;
    }
    .delivery {
      width: 11.1%;
      display: flex;
      flex-direction: column;
      //   border-right: 1px solid #181616;
      .deliveryTop {
        height: 100%;
        line-height: 70px;
        border-right: 1px solid #181616;
      }
      .noborder {
        border-right: none !important;
      }
      // .deliveryBottom {
      //   height: 50%;
      //   display: flex;
      //   line-height: 70px;
      //   justify-content: space-around;
      //   border-top: 1px solid #181616;
      //   border-right: 1px solid #181616;
      // }
    }
  }
  .customtr3 {
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #181616;
    border-left: 1px solid #181616;
    border-right: 1px solid #181616;
    // background: #00d9ff;
    display: flex;
    justify-content: space-around;
    .customText {
      width: 11.1%;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-right: 1px solid #181616;
    }
    .totalText {
      width: 20%;
    }
    .wyLayout {
      font-weight: 700;
    }
    .completeText {
      width: 11.1%;
      height: 70px;
      line-height: 70px;
      text-align: center;
    }
  }
  .customtr4 {
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #181616;
    border-left: 1px solid #181616;
    border-right: 1px solid #181616;
    background: #75d561;
    display: flex;
    justify-content: space-around;
    ::v-deep .el-input.is-disabled .el-input__inner {
      background: #75d561;
      font-weight: 700;
      color: #ff4800;
      font-size: 18px;
    }
    .customText {
      width: 11.1%;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-right: 1px solid #181616;
    }
    // .totalText {
    //   width: 11.1%;
    // }
    .bhxsbg {
      background: #f5f7fa;
      border-bottom: 1px solid #181616;
    }
    .wyLayout {
      font-weight: 700;
    }
    .completeText {
      background: #75d561;
      width: 11.1%;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-bottom: 1px solid #181616;
    }
  }
}
</style>